<script setup lang="ts">
import { useUserStore } from '@renderer/store/user'
import { useRouter } from 'vue-router';
 import { storeToRefs } from 'pinia'
const userStore = useUserStore()
const router = useRouter()
 const { currentScaleType } = storeToRefs(userStore)
// import Versions from './components/Versions.vue'


//监测网络状态
const updateOnlineStatus = () => {
  userStore.setOnline(navigator.onLine)
}

window.addEventListener('online', updateOnlineStatus)
window.addEventListener('offline', updateOnlineStatus)

//设置称类型
 window.electron.ipcRenderer.send('set-scale-type',currentScaleType.value)


window.electron.ipcRenderer.send('read-weight')

//读取称重 重量
window.electron.ipcRenderer.on('get-weight', (_, { weight, tare }) => {

  userStore.setWeight(weight)
  userStore.setTare(tare)

})

//获取实时时间
window.electron.ipcRenderer.on('interval-tick', (_,time) => {
 // console.log('interval-tick')
  userStore.setCurrentTime(time)
})



//准备升级
window.electron.ipcRenderer.on('ready-to-update', (_) => {
 // console.log('ready~~~~~~~')
  router.push('/update')
})


// window.electron.ipcRenderer.on('nothing-to-update', () => {
//         console.log('没有需要更新的')
//         // router.push('/login')
//     })

// 监听按键事件，例如 'F12' 键用于打开或关闭开发者工具
document.addEventListener('keydown', (event) => {
  if (event.key === 'F12') {  
    window.electron.ipcRenderer.send('open-main-window-devtools');
  }
});




</script>

<template>
  <router-view v-slot="{ Component }">
    <!-- ,'newcheck' -->
    <keep-alive :exclude="['transferdesc', 'newcheck', 'newtransfer', 'orderquery','rechargequery']">
      <component :is="Component" />
    </keep-alive>
  </router-view>
</template>
<style lang="scss">
#app {
  height: 100%;

}

.main_wrap {
  height: calc(100% - 50px);
  box-sizing: border-box;
  padding: 0 10px 10px 10px;
  background-color: var(--ev-c-black);
  position: relative;
  overflow: hidden;
}

/* 修改element date的默认样式 */
.el-date-picker {
  width: 600px;

  .el-date-picker__time-header,
  .el-picker-panel__footer {
    display: none;
  }

  .el-date-picker__header {

    .el-picker-panel__icon-btn,
    .el-date-picker__header-label {
      font-size: 22px;
    }

    .el-date-picker__header-label {
      line-height: 41px;
    }
  }

  .el-picker-panel__content {
    width: 570px !important;

    .el-date-table td .el-date-table-cell {
      box-sizing: content-box;
      padding: 4px 0;
    }
  }
}

//托利多字体稍小
.tuoliduo{
.title{
    font-size:28px!important;
}
font-size:26px!important;
}

//修改el-message文字大小
.el-message{
  .el-message__content{
    font-size:20px!important;
  }
}

//修改message_box文字大小
.el-message-box{
  .el-message-box__message{
    font-size:20px!important;
  }
}
</style>
